package com.yang.dao.impl;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONArray;
import com.yang.dao.BaseDAO;
import com.yang.dao.PermissionDao;
import com.yang.entity.Permissions;

@Repository
public class PermissionDaoImpl implements PermissionDao{
	
	@Autowired
	private BaseDAO<Permissions> baseDao;
	
	@Override
	public List<Permissions> getPermissionTree() {
		String hql = "from Permissions";
		return baseDao.find(hql);
	}

	@Override
	public List<Permissions> getPermissionTreeAsyc(String pid) {
		return null;
	}

	@Override
	public Permissions findOne(String id) {
		return baseDao.get(Permissions.class, id);
	}

	@Override
	public List<Permissions> findByIds(String ids) {
		if(null!=ids){
			List<String> idsList = Arrays.asList(ids.split(","));
			String hql = "from Permissions where id in :list";
			return baseDao.findIn(hql, idsList);
		}
		return null;
	}

}
